package com.lzx.iteam.net;

import android.content.Context;
import android.os.Message;
import com.lzx.iteam.bean.CloudContact;
import com.lzx.iteam.bean.PhoneNumItem;
import com.lzx.iteam.dimensioncode.Intents;
import com.lzx.iteam.util.PhoneNumberArea;
import com.lzx.iteam.util.StringUtil;
import org.json.JSONException;
import org.json.JSONObject;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.Map;

/**
 * Created by Megan on 15/12/23.
 */
public class GetCloudContactAuthMsg extends CcMsgStructure {
    private Context mmContext;
    private Message mmCallback;

    public GetCloudContactAuthMsg(Context context, Message message) {
        mmContext = context;
        mmCallback = message;
    }

    @Override
    public void onReceive(JSONObject jsonObject) {
        Map<String, Integer> map = new HashMap<String, Integer>();
        try {
            JSONObject object = jsonObject.getJSONObject("data");
            if (object.has("access")) {
                map.put("access", object.getInt("access"));
            }
            if (object.has("shield")) {
                map.put("shield", object.getInt("shield"));
            }
            if (object.has("set_type")) {
                map.put("set_type", object.getInt("set_type"));
            }
        } catch (JSONException e) {
            e.printStackTrace();
        }
        if (mmCallback != null) {
            mmCallback.arg1 = 0;
            mmCallback.obj = map;
            mmCallback.sendToTarget();
        }
    }

    @Override
    public void onError(int error, Object ret) {
        if (mmCallback != null) {
            mmCallback.arg1 = error;
            mmCallback.sendToTarget();
        }
    }
}
